package com.itheima.chapter09.io.properties;

import java.util.Map;
import java.util.Properties;
import java.util.Set;

//properties 的基本使用
public class Demo1 {
    public static void main(String[] args) {
        Properties prop =new Properties();
        //增
        prop.put("zhangsan","23");
        prop.put("lisi","26");
        prop.put("wangwu","34");
        prop.put("sunlou","56");
        prop.put("zhouyi","17");
        System.out.println(prop);
        System.out.println("------------------");
        //删
        prop.remove("zhangsan");
        System.out.println(prop);
        System.out.println("------------------");

        //改
        //put
        prop.put("zhouyi","19");
        System.out.println(prop);
        System.out.println("------------------");

        //查
        Object value = prop.get("wangwu");
        System.out.println(value);
        System.out.println(prop);
        System.out.println("------------------");
        //遍历1.
        Set<Object> keys = prop.keySet();
        for (Object key : keys) {
            Object value1 = prop.get(key);
            System.out.println(key+"  "+value1);
        }
        System.out.println("------------------");

        //遍历2.
        Set<Map.Entry<Object, Object>> entries = prop.entrySet();
        for (Map.Entry<Object, Object> entry : entries) {
            Object key = entry.getKey();
            Object value1 = entry.getValue();
            System.out.println(key+"  "+value1);
        }
    }
}
